// @ts-ignore
/* eslint-disable */
import { request } from '@umijs/max';

/** 创建用户 POST /api/user/add */
export async function postUserAdd(
  body: {
    username?: string;
    password?: string;
  },
  options?: { [key: string]: any },
) {
  return request<{ code: number; msg: string; success: boolean; data?: string }>('/api/user/add', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除用户 DELETE /api/user/del */
export async function deleteUserDel(options?: { [key: string]: any }) {
  return request<{ code: number; msg: string; success: boolean }>('/api/user/del', {
    method: 'DELETE',
    ...(options || {}),
  });
}

/** 编辑用户信息 PUT /api/user/edit */
export async function putUserEdit(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.putUserEditParams,
  options?: { [key: string]: any },
) {
  return request<{ code: number; msg: string; success: boolean }>('/api/user/edit', {
    method: 'PUT',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 获取用户 GET /api/user/get */
export async function getUserGet(options?: { [key: string]: any }) {
  return request<{
    code: number;
    msg: string;
    success: boolean;
    data: {
      user: {
        id: number;
        username: string;
        password: string;
        avatar: string;
        phone: string;
        email: string;
        gender: boolean;
        age: number;
        tags: string[];
        biography: string;
      };
    };
  }>('/api/user/get', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取用户所有仓库名 GET /api/user/getRepos */
export async function getUserGetRepos(options?: { [key: string]: any }) {
  return request<{
    code: number;
    msg?: string;
    data: API.repoData[];
  }>('/api/user/getRepos', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取用户列表 GET /api/user/list */
export async function getUserList(options?: { [key: string]: any }) {
  return request<{
    code: number;
    msg: string;
    success: boolean;
    data: {
      user1: {
        id: number;
        username: string;
        password: string;
        avatar: string;
        phone: string;
        email: string;
        gender: boolean;
        age: number;
        tags: string[];
        biography: string;
      };
      user2: {
        id: number;
        username: string;
        password: string;
        avatar: string;
        phone: string;
        email: string;
        gender: boolean;
        age: number;
        tags: string[];
        biography: string;
      };
    };
  }>('/api/user/list', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 登录 POST /api/user/login */
export async function postUserLogin(
  // 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
  params: API.postUserLoginParams,
  options?: { [key: string]: any },
) {
  return request<{ code: number; msg: string; success: boolean; data: string }>('/api/user/login', {
    method: 'POST',
    data: {
      ...params,
    },
    ...(options || {}),
  });
}
